<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/test', function () {
    $admin = \App\Models\Admin::find(5);
    $admin->password = bcrypt('hou');
    $admin->save();
    dd(2);

});
Route::get('/', function () {
    return redirect('/admin');
});

Auth::routes();


Route::any('/wechat/login', 'Home\UserCenterController@goAuthorize')->name('wechat.login');
Route::get('/wechat/callback/{qrcode_id}', 'Home\UserCenterController@callback')->name('wechat.callback');
//Route::get('/wechat/callback', 'Home\UserCenterController@callback')->name('wechat.callback');

Route::group(['middleware' => 'home.checkwechatlogin','namespace' => 'Home'], function () {

    Route::get('/qrcode/scan', 'QrcodeController@scan')->name('qrcodes.scan');
});

Route::group(['middleware' => 'auth.admin:admin','namespace' => 'Admin','prefix' => 'admin'], function () {

    Route::get('/', 'HomeController@index')->name('home');
    Route::get('/users', 'UserController@index')->name('users.index');
    Route::get('/news', 'UserController@news')->name('users.news');
    Route::get('/images', 'UserController@images')->name('users.images');
    Route::any('/menus', 'UserController@menus')->name('users.menus');
    Route::any('/getMenu', 'UserController@getMenu')->name('users.getMenu');

    Route::get('/setting/wechat', 'ConfigController@settingWechat')->name('setting.wechat');
    Route::get('/setting/menu', 'ConfigController@settingMenu')->name('setting.menu');
    Route::post('/setting/wechat/post', 'ConfigController@settingWechatPost')->name('setting.wechat.post');


    Route::post('/goods/stock', 'GoodsController@stock')->name('goods.stock');

    Route::resource('categories', 'CategoryController');
    Route::resource('configs', 'ConfigController');
    Route::resource('goods', 'GoodsController');
    Route::resource('qrcodes', 'QrcodeController');
});

Route::get('/home', 'Admin\HomeController@index')->name('home');




